package com.tuo51.manager.controller;

import com.tuo51.foudation.model.MemVerificationCache;
import com.tuo51.foudation.model.StatusResponse;
import com.tuo51.manager.service.SysSettingService;
import com.tuo51.manager.vo.SysSettingVO;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import static com.tuo51.foudation.constant.RequestConstant.TICKET;

@RestController
@RequestMapping("/mapi/sys_setting/")
@Api(value = "/mapi/sys_setting/", tags = "OP - 系统配置")
public class SysSettingController {

    @Autowired
    private SysSettingService sysSettingService;

    @Autowired
    MemVerificationCache cache;

    @PostMapping("save")
    public StatusResponse save(@RequestHeader(TICKET) String ticket, SysSettingVO entityVo) {
        String staffId = cache.getStaffId(ticket);
        return StatusResponse.success(sysSettingService.save(entityVo));
    }

    @GetMapping("setting")
    public StatusResponse setting(@RequestHeader(TICKET) String ticket) {
        String staffId = cache.getStaffId(ticket);
        return StatusResponse.success(sysSettingService.defaultSetting());
    }
}
